package com.mall.users.interceptor;


import com.mall.model.domain.UmsAdmin;

/**
 * 工具类,实现向ThreadLocal存储数据的方法
 */
public class UmsAdminHolder {

    private static ThreadLocal<com.mall.model.domain.UmsAdmin> tl = new ThreadLocal<>();

    /**
     * 存储用户对象
     * @param umsAdmin
     */
    public static void set(com.mall.model.domain.UmsAdmin umsAdmin) {
        tl.set(umsAdmin);
    }

    /**
     * 获取用户对象
     * @return
     */
    public static com.mall.model.domain.UmsAdmin get() {
        return tl.get();
    }

    /**
     * 获取用户id
     * @return
     */
    public static Long getUserId() {
        return tl.get().getId();
    }

    /**
     * 获取用户手机号
     * @return
     */
    public static String getUsername() {
        return tl.get().getUsername();
    }

    /**
     * 清空
     */
    public static void remove() {
        tl.remove();
    }
}
